#ifndef VIDEOWIN_H
#define VIDEOWIN_H
#include <QUdpSocket>
#include <QByteArray>
#include <QTimer>
#include <QDialog>
#include <QHostAddress>
#include <QIODevice>
#include <QPixmap>
#include <QFileDialog>
#include <QMessageBox>
#include <QDateTime>
#include <QSize>
#include "opencvthread.h"


#define UDP_SERVER_IP "192.168.31.163"  //UDP ip
#define UDP_SERVER_POST 8888     // udp 端口
#define VIDEO_FRAMES 150        // 视频帧发送时钟 time ms    测试最快 50ms
#define SCREENSHOT_INTERVAL 2000  // 自动截图间隔

#define DELAY_OPERATIO_start bool timer_flog_i;\
    (timerState == false)?(timer_flog_i = false):(timer_flog_i = true);\
    timer->stop();\
    timerState = false;
#define DELAY_OPERATIO_stop if(timer_flog_i==false){return;}timer->start();timerState = true;

#define DEBUG_DELAY_OPERATIO_start bool timer_flog_j;\
    (!DebugTimer->isActive())?(timer_flog_j = false):(timer_flog_j = true);\
    DebugTimer->stop();
#define DEBUG_DELAY_OPERATIO_stop if(timer_flog_j==false){;}else{DebugTimer->start();}
namespace Ui {
class VideoWin;
}

class VideoWin : public QDialog
{
    Q_OBJECT

public:
    explicit VideoWin(QWidget *parent = 0);
    ~VideoWin();

    QByteArray getData() const;
    void setData(const QByteArray &value);

private:
    Ui::VideoWin *ui;
    OpenCvThread * newOpenCvThread;
    QUdpSocket * sockaddr ;
    QTimer * timer;
    QTimer * DebugTimer;
    QByteArray Data;
    QPixmap Image;
    QPixmap OpenCvImage;
    QHostAddress serverAddress;
    quint16 serverPort;
    bool timerState;
    QString UserFilePath;
    QString DebugUserFilePath;
    int ScreenshotRed;
    int ScreenshotGre;
    QStringList List;
    int albumState;
    QPixmap PhotoImage;
private slots:
    void timeOutSlot();
    void SocketReayRead();
    void ButtonSaveSlot();
    void ButtonPlaySlot();
    void newAiDataSlot();
    void DebugTimerOutSlot();
    void ExceptionStorageSlot();
    void redChanges(int);
    void greChanges(int);
    void userPhotoSlot();
    void debugPhotoSlot();
    void nextPhotoSlot();
    void UpPhotoSlot();
signals:
    newDataSignal(QByteArray);
};

#endif // VIDEOWIN_H
